const Base = require("../base.js");
var svgCaptcha = require("svg-captcha");
/*图形验证码
 */
module.exports = class extends Base {
  async indexAction() {
    var codeConfig = {
      size: this.get("size") || 4, // 验证码长度
      ignoreChars: "", // 验证码字符中排除 0o1i
      noise: this.get("noise") || 1, // 干扰线条的数量
      fontSize: this.get("fontSize") || 62,
      color: true, //开启文字颜色
      background: this.get("background") || "#fff", //背景色
      width: this.get("width") || 150,
      height: this.get("height") || 55,
    };
    var captcha = svgCaptcha.create(codeConfig);
    this.ctx.type = "svg"; //设置返回类型
    this.success({
      img: captcha.data,
      text: captcha.text.toLowerCase(),
    });
    //     this.body = captcha.data;
  }
};
